import { Address, Hex, zeroAddress } from 'viem'
import { describe, expect, it } from 'vitest'
import { CLPositionConfig } from '../../../types'
import { encodeCLPositionManagerBurnCalldata } from './burn'

describe('encodeCLPositionManagerBurnCalldata', () => {
  it('should correctly encode burn call data', () => {
    const positionConfig: CLPositionConfig = {
      poolKey: {
        currency0: '0x8FaE29D9Fc8eC94097Acd977fC5B5134406D409c' as Address,
        currency1: '0xe61AaC040dD88A85EE00BAa861FaEaddF1DC043C' as Address,
        poolManager: '0x969D90aC74A1a5228b66440f8C8326a8dA47A5F9' as Address,
        fee: 10000,
        hooks: zeroAddress,
        parameters: {
          tickSpacing: 200,
          hooksRegistration: {},
        },
      },
      tickLower: -17400,
      tickUpper: 3400,
    }
    const tokenId = 209n
    const amount0Min = 0n
    const amount1Min = 0n
    const hookData = '0x' as Hex
    const deadline = 115792089237316195423570985008687907853269984665640564039457584007913129639935n

    const result = encodeCLPositionManagerBurnCalldata(
      tokenId,
      positionConfig,
      amount0Min,
      amount1Min,
      hookData,
      deadline
    )

    expect(result).toBe(
      '0xdd46508f0000000000000000000000000000000000000000000000000000000000000040ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000003400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030312120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000d10000000000000000000000008fae29d9fc8ec94097acd977fc5b5134406d409c000000000000000000000000e61aac040dd88a85ee00baa861faeaddf1dc043c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000969d90ac74a1a5228b66440f8c8326a8da47a5f900000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000c80000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc080000000000000000000000000000000000000000000000000000000000000d48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000008fae29d9fc8ec94097acd977fc5b5134406d409c0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000e61aac040dd88a85ee00baa861faeaddf1dc043c'
    )
  })
})
